//
//  SetItemCell.swift
//  MyTest
//
//  Created by guanzhongwang on 2021/4/10.
//

import UIKit

class SetItemArrowCell: UITableViewCell {
    weak var delegate:SetItemCellDelegate?
    var item:SetItemModel?
    private var arrow:UIImageView = UIImageView()
    private var tipLabel:UILabel = UILabel()
    private var titleLabel:UILabel = UILabel()
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
        
    }
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        contentView.addSubview(titleLabel)
        titleLabel.snp.makeConstraints({
            $0.left.equalTo(15)
            $0.centerY.equalToSuperview()
        })
        titleLabel.font  = Font_Size_14
        tipLabel.font = Font_Size_14
        tipLabel.textColor = .lightGray
        contentView.addSubview(tipLabel)
        tipLabel.snp.makeConstraints({
            $0.right.equalToSuperview().inset(30)
            $0.centerY.equalToSuperview()
        })
        let image = UIImage(named: "arrowright")?.withRenderingMode(UIImage.RenderingMode.alwaysTemplate)
        arrow.tintColor = B999_TITLE_COLOR
        arrow.image = image
        arrow.tintColor = .lightGray
        contentView.addSubview(arrow)
        arrow.snp.makeConstraints({
            $0.centerY.equalToSuperview()
            $0.right.equalToSuperview().inset(5)
        })
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)
        // Configure the view for the selected state
        
    }
    func binding(_ data:SetItemModel) {
        self.tipLabel.text = data.tip
        self.arrow.isHidden = data.hiddenArrow
        if(data.subTitle != ""){
            let text = data.title + "\n" + data.subTitle
            self.titleLabel.attributedText = text.getAttributedString(data.subTitle, subColor: B999_TITLE_COLOR, subFont: Font_Size_12, lineSpace: 5.0)
            titleLabel.numberOfLines = 2
        }else{
            self.titleLabel.text = data.title
            titleLabel.numberOfLines = 1
        }
    }
}
